package cn.zhaozhiqi.remote.fallback;

import cn.zhaozhiqi.constants.ErrorCode;
import cn.zhaozhiqi.remote.api.ILoginFeignClient;
import cn.zhaozhiqi.remote.dto.LoginDto;
import cn.zhaozhiqi.result.JSONResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginFeignClientFallbackFactory implements FallbackFactory<ILoginFeignClient> {
    @Override
    public ILoginFeignClient create(Throwable cause) {
        return new ILoginFeignClient() {
            @Override
            public JSONResult register(LoginDto dto) {
                return JSONResult.error(ErrorCode.SERVICE_REQUEST_ERROR);
            }
        };
    }
}
